﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Principal.master" AutoEventWireup="true"
    CodeFile="Tarifa.aspx.cs" Inherits="Tarifa" Title="Untitled Page" %>
<%@ OutputCache Duration="1" Location="none" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h1>
        Tarifas</h1>
    <asp:FormView ID="FormViewTarifa" runat="server" DefaultMode="Insert" DataSourceID="ObjectDataSourceTarifa"
        HorizontalAlign="Center" OnItemInserted="FormViewTarifa_ItemInserted" Visible="False">
        <InsertItemTemplate>
            <table style="width: 100%;">
                <tr>
                    <td>
                        DescripcionTarifa:
                    </td>
                    <td>
                        <asp:TextBox ID="DescripcionTarifaTextBox" runat="server" Text='<%# Bind("DescripcionTarifa") %>' />
                    </td>
                </tr>
                <tr>
                    <td>
                        ValorTarifa:
                    </td>
                    <td>
                        <asp:TextBox ID="ValorTarifaTextBox" runat="server" Text='<%# Bind("ValorTarifa") %>' />
                    </td>
                </tr>
                <tr>
                    <td>
                        PerfilUsuarioTarifa:
                    </td>
                    <td>
                        <asp:TextBox ID="PerfilUsuarioTarifaTextBox" runat="server" Text='<%# Bind("PerfilUsuarioTarifa") %>' />
                    </td>
                </tr>
                <tr>
                    <td>
                        CodigoMenu:
                    </td>
                    <td>
                        <asp:DropDownList ID="DropDownListCodigoMenu" runat="server" DataSourceID="ObjectDataSourceMenu"
                            DataTextField="Nombre" DataValueField="Codigo" OnSelectedIndexChanged="DropDownListCodigoMenu_SelectedIndexChanged">
                        </asp:DropDownList>
                        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="DropDownListCodigoMenu"
                            ErrorMessage="El campo código menú es obligatorio." Operator="GreaterThan" Type="Integer"
                            ValidationGroup="Validadores" ValueToCompare="0">*</asp:CompareValidator>
                        <asp:HiddenField ID="HiddenFieldCodigoMenu" runat="server" Value='<%# Bind("CodigoMenu") %>' />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                            Text="Insertar" ValidationGroup="Validadores" />
                        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
                            CommandName="Cancel" OnClick="InsertCancelButton_Click" Text="Cancelar" />
                    </td>
                </tr>
            </table>
        </InsertItemTemplate>
    </asp:FormView>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        CellPadding="4" DataSourceID="ObjectDataSourceTarifa" ForeColor="#333333" GridLines="None"
        HorizontalAlign="Center" CssClass="detalle">
        <RowStyle BackColor="#EFF3FB" />
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Actualizar"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Cancelar"></asp:LinkButton>
                </EditItemTemplate>
                <HeaderTemplate>
                    <asp:LinkButton ID="LinkButtonAddNew" runat="server" OnClick="LinkButtonAddNew_Click">Add 
                    new</asp:LinkButton>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Modificar"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="Eliminar"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Codigo" HeaderText="Codigo" ReadOnly="True" SortExpression="Codigo" />
            <asp:BoundField DataField="DescripcionTarifa" HeaderText="DescripcionTarifa" SortExpression="DescripcionTarifa" />
            <asp:BoundField DataField="ValorTarifa" HeaderText="ValorTarifa" SortExpression="ValorTarifa" />
            <asp:BoundField DataField="PerfilUsuarioTarifa" HeaderText="PerfilUsuarioTarifa"
                SortExpression="PerfilUsuarioTarifa" />
            <asp:TemplateField HeaderText="CodigoMenu" SortExpression="CodigoMenu">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownListCodigoMenu" runat="server" DataSourceID="ObjectDataSourceMenu"
                        DataTextField="Nombre" DataValueField="Codigo" SelectedValue='<%# Bind("CodigoMenuConvertido") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:DropDownList ID="DropDownListCodigoMenu" runat="server" DataSourceID="ObjectDataSourceMenu"
                        DataTextField="Nombre" DataValueField="Codigo" SelectedValue='<%# Bind("CodigoMenuConvertido") %>'
                        Enabled="False">
                    </asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <EmptyDataTemplate>
            No hay datos en Tarifa
            <asp:LinkButton ID="LinkButtonAddNew" runat="server" OnClick="LinkButtonAddNew_Click">Add 
            new</asp:LinkButton>
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSourceTarifa" runat="server" DeleteMethod="eliminarTarifa"
        InsertMethod="crearTarifa" SelectMethod="consultarTarifas" TypeName="Libreria.SIG.Negocio.TarifaNegocio"
        UpdateMethod="actualizarTarifa">
        <DeleteParameters>
            <asp:Parameter Name="Codigo" Type="Int32" />
            <asp:Parameter Name="cadenaDeConexion" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Codigo" Type="Int32" />
            <asp:Parameter Name="DescripcionTarifa" Type="String" />
            <asp:Parameter Name="ValorTarifa" Type="Double" />
            <asp:Parameter Name="PerfilUsuarioTarifa" Type="String" />
            <asp:Parameter Name="CodigoMenuConvertido" Type="Int32" />
            <asp:Parameter Name="cadenaDeConexion" Type="String" />
        </UpdateParameters>
        <SelectParameters>
            <asp:SessionParameter Name="cadenaDeConexion" SessionField="CadenaDeConexion" Type="String" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="Codigo" Type="Int32" />
            <asp:Parameter Name="DescripcionTarifa" Type="String" />
            <asp:Parameter Name="ValorTarifa" Type="Double" />
            <asp:Parameter Name="PerfilUsuarioTarifa" Type="String" />
            <asp:Parameter Name="CodigoMenu" Type="Int32" />
            <asp:Parameter Name="cadenaDeConexion" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSourceMenu" runat="server" SelectMethod="consultarMenus"
        TypeName="Libreria.SIG.Negocio.MenuNegocio">
        <SelectParameters>
            <asp:SessionParameter Name="cadenaDeConexion" SessionField="CadenaDeConexion" Type="String" />
            <asp:Parameter DefaultValue="true" Name="bolControlVacio" Type="Boolean" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>
